<?php declare(strict_types=1);

namespace App\Crontab;

use Hyperf\Crontab\Annotation\Crontab;
use Psr\Log\LoggerInterface;

class Tasks
{

    protected LoggerInterface $logger;

    public function __construct()
    {
        $this->logger = getLogger('task');
    }

    private function addLog(string $funcName, ?string $result): void
    {
        $this->logger->info("［" . $funcName . "］Executed：{$result}");
    }

    #[Crontab(rule: "0 0-30/10 3 * * *", name: 'demo', memo: "Demo", enable: true)]
    public function demo(): void
    {
        $this->addLog(__METHOD__, 'demo');
    }

}